import { hsHandleTableDateTime, isDate } from '@hs-admin/utils'

// 处理表格中返回数据为日期格式的字符串
export function handleTableShowDate(item: any, key: string) {
  if (isDate(item[key]) && isNaN(item[key]) && item[key].length !== 10) {
    item[key] = hsHandleTableDateTime(item[key])
  }
}

export function getKeyValueArr(value: number | string | undefined, list: any[]) {
  if (value !== undefined) {
    const tmp = list.find((x: any) => {
      return x.value === value
    })
    if (tmp) return tmp.label
    return ''
  } else {
    return list
  }
}
